/**
 * Dear programmer:
 * When I wrote this code, only god and I knew how it worked.
 * Now, only god knows it!
 *
 * @author: Pegasus  Date: 2018/11/21 Time: 23:05
 */

import React from 'react';
import {Image, StyleSheet} from 'react-native';
import {createBottomTabNavigator, createAppContainer} from 'react-navigation';
import ReportScreen from "../screen/report/Report/ReportScreen"
import JobScreen from "../screen/job/JobScreen/JobScreen"
import ContactsScreen from "../screen/contacts/ContactsScreen/ContactsScreen"
import RoomDiskScreen from "../screen/RoomDisk/RoomDiskScreen/RoomDiskScreen"
import MineScreen from "../screen/mine/MineScreen/MineScreen"
import {COLOR_LINK} from "../constant/PHColors"
import global from "../configuration/global";

export const MainNavigator = createBottomTabNavigator({
  /*ReportScreen: {
    screen: ReportScreen,
    navigationOptions: {
      tabBarLabel: '报表',
      tabBarIcon: ({tintColor, focused}) => (
        focused
          ?
          <Image
            source={require('../resource/tabmenu/bq_baobiao02.png')}
            style={styles.tabBarIcon}
          />
          :
          <Image
            source={require('../resource/tabmenu/bq_baobiao01.png')}
            style={styles.tabBarIcon}
          />
      )
    }
  },*/
  /*RoomDiskScreen: {
      screen: RoomDiskScreen,
      navigationOptions: {
          tabBarLabel: '房态盘',
          tabBarIcon: ({tintColor, focused}) => (
              focused
                  ?
                  <Image
                      source={require('../resource/tabmenu/bq_baobiao02.png')}
                      style={styles.tabBarIcon}
                  />
                  :
                  <Image
                      source={require('../resource/tabmenu/bq_baobiao01.png')}
                      style={styles.tabBarIcon}
                  />
          )
      }
  },*/
  JobScreen: {
    screen: JobScreen,
    navigationOptions: {
      tabBarLabel: '工作',
      tabBarIcon: ({tintColor, focused}) => (
        focused
          ?
          <Image
            source={require('../resource/tabmenu/bq_work02.png')}
            style={styles.tabBarIcon}
          />
          :
          <Image
            source={require('../resource/tabmenu/bq_work01.png')}
            style={styles.tabBarIcon}
          />
      )
    }
  },
  ContactsScreen: {
    screen: ContactsScreen,
    navigationOptions: {
      tabBarLabel: '通讯录',
      tabBarIcon: ({tintColor, focused}) => (
        focused
          ?
          <Image
            source={require('../resource/tabmenu/bq_tongxunlu02.png')}
            style={styles.tabBarIcon}
          />
          :
          <Image
            source={require('../resource/tabmenu/bq_tongxunlu01.png')}
            style={styles.tabBarIcon}
          />
      )
    }
  },
  MineScreen: {
    screen: MineScreen,
    navigationOptions: {
      tabBarLabel: '个人',
      tabBarIcon: ({tintColor, focused}) => (
        focused
          ?
          <Image
            source={require('../resource/tabmenu/bq_user02.png')}
            style={styles.tabBarIcon}
          />
          :
          <Image
            source={require('../resource/tabmenu/bq_user01.png')}
            style={styles.tabBarIcon}
          />
      )
    }
  }
}, {
  tabBarOptions: {
    activeTintColor: COLOR_LINK, // 文字和图片选中颜色
    indicatorStyle: {
      height: 0
    },
    showIcon: true
  }
});

const styles = StyleSheet.create({
  tabBarIcon: {
    width: 22,
    height: 22
  }
})

MainNavigator.navigationOptions = ({navigation}) => {
  let screen = navigation.state.routes[navigation.state.index];
  let {routeName, params} = screen;
  let headerTitle;

  global.AppType = '工程';

  switch (routeName) {
    case 'ReportScreen': {
      return {...ReportScreen.navigationOptions({navigation})}
    }
    case 'JobScreen': {
      return {...JobScreen.navigationOptions({navigation})}
    }
    case 'ContactsScreen': {
      return {...ContactsScreen.navigationOptions({navigation})}
    }
    case 'MineScreen': {
      return {...MineScreen.navigationOptions({navigation})}
    }
    /*case 'RoomDiskScreen': {
        return {...RoomDiskScreen.navigationOptions({navigation})}
    }*/
  }
  return {
    headerTitle,
  };
};